<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新增印章</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="../lib/layui/css/layui.css">
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <link rel="stylesheet" href="../css/jquery-ui-1.9.2.custom.css">
    <script type="text/javascript" src="../lib/layui/layui.all.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/jquery.min.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
    <script type="text/javascript" src="../js/commonutil.js"></script>
    <script src="./function.js" charset="utf-8"></script>
    <script src="../js/jquery/jquery-1.12.4.min.js" charset="utf-8"></script>
    <script src="../js/jquery-ui/jquery-ui-1.9.2.custom.js" charset="utf-8"></script>

    <style type="text/css">
        #parent {
            border: 1px #EEE solid;
            width: 350px;
            height: 20px;
            margin: 0 auto;
        }

        #child {
            width: 0%;
            height: 10px;
            background-color: green;
        }

        p {
            text-align: center;
            color: fuchsia;
        }
    </style>
</head>
<body>
<div class="edit-form-class" style="padding-top: 20px;">
    <form class="layui-form" id="addSealInfoForm">
        <div class="layui-form-item">
            <label class="layui-form-label">*企业名称</label>
            <div class="layui-input-block">
                <input type="text" id="sealOrg" name="sealOrg" maxlength="32" lay-verify="required|sealOrgVerify" style="width: 350px"
                       autocomplete="off" placeholder="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">*证件类型</label>
            <div class="layui-input-block" style="width: 350px">
                <select name="identificationType" lay-filter="identificationType" id="identificationType"
                        lay-verify="required|identificationTypeVerify">
                </select>
            </div>
        </div>
        <div class="layui-form-item">
        <label class="layui-form-label">*证件号码</label>
            <div class="layui-input-block">
                <input type="text" id="identificationNo" name="identificationNo" maxlength="30"
                       lay-verify="required|identificationNoVerify" style="width: 350px" autocomplete="off"
                       placeholder="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">*自定义编码</label>
            <div class="layui-input-block">
                <input type="radio" name="customSealCode" value="1" title="是" lay-filter="customSealCodeFilter">
                <input type="radio" name="customSealCode" value="0" title="否" checked=""
                       lay-filter="customSealCodeFilter">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">*印章编码</label>
            <div class="layui-input-block">
                <input type="text" id="sealCode" name="sealCode"
                       style="width: 350px" autocomplete="off" placeholder="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">*印章关键字</label>
            <div class="layui-input-block">
                <input type="text" id="keyWords" name="keyWords" lay-verify="required|keyWordsVerify" maxlength="12"
                       style="width: 350px" autocomplete="off" placeholder="不超过四个汉字,例如:_利_通_" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block" style="padding-left: 50px;padding-top: 20px">
                <div class="layui-btn" lay-submit="" autocomplete="off" lay-filter="submitBtn" id="submitBtn">保存</div>
                <div class="layui-btn layui-btn-primary" id="closeWin">取消</div>
            </div>
        </div>
    </form>
</div>
</body>

<script>
    jQuery(function () {
        layui.use(['laypage', 'jquery', 'layer', 'table', 'form', 'upload'], function () {
            let form = layui.form;
            let upload = layui.upload;
            //初始化公章证件类型
            queryCertType(form);
            //初始化个人证件类型
            queryPersonCertType(form);
            //sealName自动补全
            autocompleteName();
            //证件类型和证件号码监听事件
            // sealTypeAndIdNoListener(form);
            //文件上传
            let uploadUrl = serverPre + "/manager/scs/v2/sealInfo/upload";
            uploadFile(upload, uploadUrl);
            form.render();
            //隐藏sealcode输入框
            $("#sealCode").parent().parent().hide();
            //Radio监听
            form.on('radio(customSealCodeFilter)', function (data) {
                if (this.value == '1') {
                    $("#sealCode").parent().parent().show();
                    // autocompleteCode(form);
                } else {
                    $("#sealCode").parent().parent().hide();
                }
            });
        });
    });

    //提交
    $('#submitBtn').click(function () {
        let url = serverPre + "/manager/scs/v2/sealInfo/saveFdd";
        let formData = serializeObject($("#addSealInfoForm"));
        debugger
        let commitData = JSON.stringify({
            "sealOrg": formData.sealOrg,
            "identificationType": formData.identificationType,
            "identificationNo": formData.identificationNo,
            "sealName": formData.sealName,
            "sealCode": formData.sealCode,
            "keyWords": formData.keyWords,
            "sealSource": 2
        });
        submitForm(commitData, url);
    });

    //取消
    $("#closeWin").click(function () {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index);
    });
</script>
</html>
